{%- macro book_list(data,currentId,node) %}
    <ul class="book-toc toc">
    {% for nodeId,item in data.toc %}

        <li id="book-node-id-{{ nodeId }}">

            {% if is_array(item) AND item.son is defined AND item.son is not empty %}
                <a{% if currentId == nodeId %} class="active"{% endif %} href="{{ url(['for':'node','contentModel':node.contentModel,'id':nodeId]) }}">{{ item.title }}</a>

                {% if currentId == nodeId AND node.bodyToc is defined %}
                    <ul class="toc content-toc">
                        {% for contentToc in node.bodyToc %}
                            <li>{{ contentToc }}</li>
                        {% endfor %}
                    </ul>
                {% endif %}

                {{ book_list(item.son,currentId,node) }}
            {% else %}
                <a{% if currentId == nodeId %} class="active"{% endif %} href="{{ url(['for':'node','contentModel':node.contentModel,'id':nodeId]) }}">{{ item }}</a>

                {% if currentId == nodeId AND node.bodyToc is defined %}
                    <ul class="toc content-toc">
                        {% for contentToc in node.bodyToc %}
                            <li>{{ contentToc }}</li>
                        {% endfor %}
                    </ul>
                {% endif %}

            {% endif %}

        </li>

    {% endfor %}
    </ul>
{%- endmacro %}
<div class="block block-bookToc" id="{{ data.getId() }}">
    <h3 class="block-title">
        <a href="{{ url(['for':'node','contentModel':node.contentModel,'id':bookNode.getId()]) }}">
            {{ bookNode.title }}
        </a>
    </h3>

    {% if data %}
        {{ book_list(bookToc,currentId,currentNode) }}
    {% endif %}
</div>